package c.j.a.d.b.c;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import c.j.a.d.b.e.b;
import java.io.File;

/* compiled from: DownloadDBHelper */
public class a extends SQLiteOpenHelper {
    public static volatile a b;
    public boolean a = false;

    public a() {
        super(b.a(), "downloader.db", null, 13);
    }

    public SQLiteDatabase getReadableDatabase() {
        Context a = b.a();
        if (this.a || a == null) {
            return super.getReadableDatabase();
        }
        try {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("/data/data/");
            stringBuilder.append(a.getPackageName());
            stringBuilder.append("/database/main/");
            File file = new File(stringBuilder.toString());
            if (!file.exists()) {
                file.mkdir();
            }
            super.getReadableDatabase().execSQL("PRAGMA temp_store_directory = tempDir");
            this.a = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.getReadableDatabase();
    }

    public void onCreate(SQLiteDatabase sQLiteDatabase) {
        sQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS downloader( _id INTEGER PRIMARY KEY, url TEXT, savePath TEXT, tempPath TEXT, name TEXT, chunkCount INTEGER, status INTEGER, curBytes INTEGER, totalBytes INTEGER, eTag TEXT, onlyWifi INTEGER, force INTEGER, retryCount INTEGER, extra TEXT, mimeType TEXT, title TEXT, notificationEnable INTEGER, notificationVisibility INTEGER, isFirstDownload INTEGER, isFirstSuccess INTEGER, needHttpsToHttpRetry INTEGER, downloadTime INTEGER, packageName TEXT, md5 TEXT, retryDelay INTEGER, curRetryTime INTEGER, retryDelayStatus INTEGER, defaultHttpServiceBackUp INTEGER, chunkRunnableReuse INTEGER, retryDelayTimeArray TEXT, chunkDowngradeRetry INTEGER, backUpUrlsStr TEXT, backUpUrlRetryCount INTEGER, realDownloadTime INTEGER, retryScheduleMinutes INTEGER, independentProcess INTEGER, auxiliaryJsonobjectString TEXT, iconUrl TEXT, appVersionCode INTEGER)");
        sQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS downloadChunk( _id INTEGER, chunkIndex INTEGER, startOffset INTEGER, curOffset INTEGER, endOffset INTEGER, chunkContentLen INTEGER, hostChunkIndex INTEGER )");
    }

    public void onDowngrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
        if (c.j.a.d.b.g.a.b()) {
            c.j.a.d.b.g.a.d("DownloaderLogger", "onDowngrade");
        }
    }

    /* JADX WARNING: Missing block: B:2:0x0019, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD isFirstDownload INTEGER");
     */
    /* JADX WARNING: Missing block: B:3:0x001e, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD isFirstSuccess INTEGER");
     */
    /* JADX WARNING: Missing block: B:4:0x0023, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD needHttpsToHttpRetry INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD downloadTime INTEGER");
     */
    /* JADX WARNING: Missing block: B:5:0x002d, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD packageName TEXT");
            r1.execSQL("ALTER TABLE downloader ADD md5 TEXT");
     */
    /* JADX WARNING: Missing block: B:6:0x0037, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD retryDelay INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD curRetryTime INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD retryDelayStatus INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD defaultHttpServiceBackUp INTEGER");
     */
    /* JADX WARNING: Missing block: B:7:0x004b, code skipped:
            r1.execSQL("ALTER TABLE downloadChunk ADD chunkContentLen INTEGER");
            r1.execSQL("ALTER TABLE downloadChunk ADD hostChunkIndex INTEGER");
     */
    /* JADX WARNING: Missing block: B:8:0x0055, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD chunkRunnableReuse INTEGER");
     */
    /* JADX WARNING: Missing block: B:9:0x005a, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD retryDelayTimeArray TEXT");
     */
    /* JADX WARNING: Missing block: B:10:0x005f, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD chunkDowngradeRetry INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD backUpUrlsStr TEXT");
            r1.execSQL("ALTER TABLE downloader ADD backUpUrlRetryCount INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD realDownloadTime INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD retryScheduleMinutes INTEGER");
            r1.execSQL("ALTER TABLE downloader ADD independentProcess INTEGER");
     */
    /* JADX WARNING: Missing block: B:11:0x007d, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD auxiliaryJsonobjectString TEXT");
     */
    /* JADX WARNING: Missing block: B:12:0x0082, code skipped:
            r1.execSQL("ALTER TABLE downloader ADD iconUrl TEXT");
            r1.execSQL("ALTER TABLE downloader ADD appVersionCode INTEGER");
     */
    /* JADX WARNING: Missing block: B:13:?, code skipped:
            return;
     */
    public void onUpgrade(android.database.sqlite.SQLiteDatabase r1, int r2, int r3) {
        /*
        r0 = this;
        switch(r2) {
            case 1: goto L_0x0005;
            case 2: goto L_0x0019;
            case 3: goto L_0x001e;
            case 4: goto L_0x0023;
            case 5: goto L_0x002d;
            case 6: goto L_0x0037;
            case 7: goto L_0x004b;
            case 8: goto L_0x0055;
            case 9: goto L_0x005a;
            case 10: goto L_0x005f;
            case 11: goto L_0x007d;
            case 12: goto L_0x0082;
            default: goto L_0x0003;
        };
    L_0x0003:
        goto L_0x008c;
    L_0x0005:
        r2 = "ALTER TABLE downloader ADD mimeType TEXT";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD title TEXT";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD notificationEnable INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD notificationVisibility INTEGER";
        r1.execSQL(r2);
    L_0x0019:
        r2 = "ALTER TABLE downloader ADD isFirstDownload INTEGER";
        r1.execSQL(r2);
    L_0x001e:
        r2 = "ALTER TABLE downloader ADD isFirstSuccess INTEGER";
        r1.execSQL(r2);
    L_0x0023:
        r2 = "ALTER TABLE downloader ADD needHttpsToHttpRetry INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD downloadTime INTEGER";
        r1.execSQL(r2);
    L_0x002d:
        r2 = "ALTER TABLE downloader ADD packageName TEXT";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD md5 TEXT";
        r1.execSQL(r2);
    L_0x0037:
        r2 = "ALTER TABLE downloader ADD retryDelay INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD curRetryTime INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD retryDelayStatus INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD defaultHttpServiceBackUp INTEGER";
        r1.execSQL(r2);
    L_0x004b:
        r2 = "ALTER TABLE downloadChunk ADD chunkContentLen INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloadChunk ADD hostChunkIndex INTEGER";
        r1.execSQL(r2);
    L_0x0055:
        r2 = "ALTER TABLE downloader ADD chunkRunnableReuse INTEGER";
        r1.execSQL(r2);
    L_0x005a:
        r2 = "ALTER TABLE downloader ADD retryDelayTimeArray TEXT";
        r1.execSQL(r2);
    L_0x005f:
        r2 = "ALTER TABLE downloader ADD chunkDowngradeRetry INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD backUpUrlsStr TEXT";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD backUpUrlRetryCount INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD realDownloadTime INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD retryScheduleMinutes INTEGER";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD independentProcess INTEGER";
        r1.execSQL(r2);
    L_0x007d:
        r2 = "ALTER TABLE downloader ADD auxiliaryJsonobjectString TEXT";
        r1.execSQL(r2);
    L_0x0082:
        r2 = "ALTER TABLE downloader ADD iconUrl TEXT";
        r1.execSQL(r2);
        r2 = "ALTER TABLE downloader ADD appVersionCode INTEGER";
        r1.execSQL(r2);
    L_0x008c:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.d.b.c.a.onUpgrade(android.database.sqlite.SQLiteDatabase, int, int):void");
    }
}
